<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
   
    <home-page></home-page>
  </div>
  <script src="./vue.global.js"></script>
  <script src="./axios.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp({
    });
    // 将组件公共特性定义在 混入对象中 （结构和组件的option一样）
    const mixin = {
      data() {
        return {
          msg: 'hello vue'
        }
      },
      methods: {
        changeMsg() {
          this.msg = 'hello react'
        }
      },
      computed: {
        reverseMsg(){
          return this.msg.split('').reverse().join('');
        }
      }
    }
    const HomePage = {
      template: `
        <div>
          <h1>hom页</h1>
          <button @click="changeMsg">修改msg</button>
          {{ msg }}
          <hr/>
          {{ reverseMsg }}
        </div>
      `,
      
      data() {
        return {
          msg: '组件自己的数据'
        }
      },
      // 在组件中定义 mixins 属性 将混入中的 特性注入该组件
      mixins: [mixin]
    }

    app.component('HomePage', HomePage)
    app.mount('#app')
  </script>
</body>
</html>